use "C:\Users\blake.emidy\OneDrive - The University of Montana\FEVS 2022\FEVS2022_Clean_2-22-23.dta", clear

gen racesex = .
replace racesex = 0 if race==0 & male==1
replace racesex = 1 if race==1 & male==1
replace racesex = 2 if race==2 & male==1
replace racesex = 3 if race==3 & male==1
replace racesex = 4 if race==4 & male==1
replace racesex = 5 if race==0 & male==0
replace racesex = 6 if race==1 & male==0
replace racesex = 7 if race==2 & male==0
replace racesex = 8 if race==3 & male==0
replace racesex = 9 if race==4 & male==0
label var racesex "Race and Gender"
label define rs 0 "White Man" 1 "Black Man" 2 "Hispanic Man" 3 "Asian Man" 4 "Other Man" 5 "White Woman" 6 "Black Woman" 7 "Hispanic Woman" 8 "Asian Woman" 9 "Other Woman"
label val racesex rs
tab racesex race

factor q73 q74 q75 [aw=post] // excluding q1 & q46 
rotate
alpha q73 q74 q75, item 
egen admiss = rmiss(q73 q74 q75)
egen advance = rmean(q73 q74 q75) if admiss<2

gen rq84 = .
replace rq84 = 1 if q84==5
replace rq84 = 2 if q84==4
replace rq84 = 3 if q84==3
replace rq84 = 4 if q84==2
replace rq84 = 5 if q84==1
tab rq84 q84, m

clonevar access = q84
replace access = 3 if q84==0
tab access q84

factor q76-q81 [aw=post] //
rotate
alpha q76-q78, item // belongingness
alpha q79-q81, item // uniqueness
egen bemiss = rmiss(q76-q78)
egen belong = rmean(q76-q78) if bemiss<2
egen unmiss = rmiss(q79-q81)
egen unique = rmean(q79-q81) if unmiss<2

factor q85-q88 [aw=post] //
rotate
alpha q85-q88, item // affective commitment
egen acmiss = rmiss(q85-q88)
egen affcom = rmean(q85-q88) if acmiss<2

factor q45 q71 q72 [aw=post] //
rotate
alpha q45 q71 q72, item // diversity
egen dimiss = rmiss(q45 q71 q72)
egen diverse = rmean(q45 q71 q72) if dimiss<2

tab dmil
encode dmil, gen(dvet)
tab dvet, nol
gen vet = .
replace vet=1 if dvet==1
replace vet=0 if dvet==2
label var vet "Veteran Status"
label val vet yno
tab vet, m 

factor q2-q4 q6-q7 [aw=post]
rotate
alpha q2-q4 q6-q7, item // 5-measure intrinsic work experience
egen ji5miss = rmiss(q2-q4 q6-q7)
egen job5 = rmean(q2-q4 q6-q7) if ji5miss<3

factor q2 q3 q6 [aw=post]
rotate
alpha q2 q3 q6, item // 3-measure intrinsic work experience
egen ji3miss = rmiss(q2 q3 q6)
egen job3 = rmean(q2 q3 q6) if ji3miss<2

mark hughes
markout hughes racesex disability agcy fedten super over40 vet advance affcom q68 q84 belong unique diverse job3
keep if hughes==1

factor q45 q71-q81 [aw=post] // TABLE 1
rotate, oblimin oblique normalize
estat common

factor q45 q71-q81 q68 q85-q88 q2 q3 q6 [aw=post] // All vars
rotate


tab race, gen(rc)
tab q84, gen(acc)
tab fedten, gen(fdt)
tab agcy, gen(div)
tab racesex, gen(rs)

tab agcy [aw=post], sum(disability)
gen agydis = .			
replace agydis = 	2.3181425	if agcy == 	1
replace agydis = 	1.420543	if agcy == 	2
replace agydis = 	.572545	if agcy == 	3
replace agydis = 	2.4054661	if agcy == 	4
replace agydis = 	1.363108	if agcy == 	5
replace agydis = 	.9191696	if agcy == 	6
replace agydis = 	2.1004547	if agcy == 	7
replace agydis = 	1.3752293	if agcy == 	8
replace agydis = 	1.8984691	if agcy == 	9
replace agydis = 	1.578342	if agcy == 	10
replace agydis = 	.3691861	if agcy == 	11
replace agydis = 	1.3030327	if agcy == 	12
replace agydis = 	4.1562217	if agcy == 	13
replace agydis = 	1.2698257	if agcy == 	14
replace agydis = 	.5490672	if agcy == 	15
replace agydis = 	1.6386585	if agcy == 	16
replace agydis = 	1.1047395	if agcy == 	17
replace agydis = 	1.392762	if agcy == 	18
replace agydis = 	1.58044	if agcy == 	19
replace agydis = 	1.5664116	if agcy == 	20
replace agydis = 	.670086	if agcy == 	21
replace agydis = 	1.1073104	if agcy == 	22
replace agydis = 	.6116061	if agcy == 	23
replace agydis = 	2.2912535	if agcy == 	24
replace agydis = 	.951101	if agcy == 	25
replace agydis = 	1.1560162	if agcy == 	26
replace agydis = 	1.2190999	if agcy == 	27
replace agydis = 	1.9898381	if agcy == 	28
replace agydis = 	1.7879644	if agcy == 	29
replace agydis = 	1.5199773	if agcy == 	30
sum agydis [aw=post]
gen zerodis = agydis - 1.837293


tab q84 disability [aw=post], nofreq col
tab q84 disability [aw=post] if q84>0 & q84<., nofreq col

tab disability [aw=post] if q84>0 & q84<., sum(q84)
tab disability [aw=post], sum(acc1)
tab disability [aw=post], sum(male)
tab disability [aw=post], sum(rc1)
tab disability [aw=post], sum(rc2)
tab disability [aw=post], sum(rc3)
tab disability [aw=post], sum(rc4)
tab disability [aw=post], sum(rc5)
tab disability [aw=post], sum(over40)
tab disability [aw=post], sum(super)
tab disability [aw=post], sum(fdt1)
tab disability [aw=post], sum(fdt2)
tab disability [aw=post], sum(fdt3)
tab disability [aw=post], sum(advance)
tab disability [aw=post], sum(belong)
tab disability [aw=post], sum(unique)
tab disability [aw=post], sum(q68)
tab disability [aw=post], sum(affcom)
tab disability [aw=post], sum(diverse)

corr advance belong unique q68 affcom disability q84 if q84>0 & q84<. [aw=post]

**Table 3
reg q84 i.disability##c.agydis i.racesex i.over40 i.super i.vet i.fedten [aw=post] if q84>0 & q84<., rob
reg diverse i.disability##c.agydis i.racesex i.over40 i.super i.vet i.fedten [aw=post], rob
reg advance i.disability##c.agydis i.racesex i.over40 i.super i.vet i.fedten [aw=post], rob
reg unique i.disability##c.agydis i.racesex i.over40 i.super i.vet i.fedten [aw=post], rob
reg belong i.disability##c.agydis i.racesex i.over40 i.super i.vet i.fedten [aw=post], rob
reg q68 i.disability##c.agydis i.racesex i.over40 i.super i.vet i.fedten [aw=post], rob
reg affcom i.disability##c.agydis i.racesex i.over40 i.super i.vet i.fedten [aw=post], rob
reg job3 i.disability##c.agydis i.racesex i.over40 i.super i.vet i.fedten [aw=post], rob

**Table 4
reg q84 disability i.racesex i.over40 i.super i.vet i.fedten i.agcy [aw=post] if q84>0 & q84<., rob
outreg2 using "C:\Users\blake.emidy\OneDrive - The University of Montana\FEVS 2022\EIA_1-3-24.xls", label tstat excel  dec(2) append
reg diverse disability i.racesex i.over40 i.super i.vet i.fedten i.agcy [aw=post], rob
outreg2 using "C:\Users\blake.emidy\OneDrive - The University of Montana\FEVS 2022\EIA_1-3-24.xls", label tstat excel  dec(2) append
reg diverse disability acc1 access i.racesex i.over40 i.super i.vet i.fedten i.agcy [aw=post], rob
outreg2 using "C:\Users\blake.emidy\OneDrive - The University of Montana\FEVS 2022\EIA_1-3-24.xls", label tstat excel  dec(2) append
reg advance disability i.racesex i.over40 i.super i.vet i.fedten i.agcy [aw=post], rob
outreg2 using "C:\Users\blake.emidy\OneDrive - The University of Montana\FEVS 2022\EIA_1-3-24.xls", label tstat excel  dec(2) append
reg advance disability acc1 access i.racesex i.over40 i.super i.vet i.fedten i.agcy [aw=post], rob
outreg2 using "C:\Users\blake.emidy\OneDrive - The University of Montana\FEVS 2022\EIA_1-3-24.xls", label tstat excel  dec(2) append
reg unique disability i.racesex i.over40 i.super i.vet i.fedten i.agcy [aw=post], rob
outreg2 using "C:\Users\blake.emidy\OneDrive - The University of Montana\FEVS 2022\EIA_1-3-24.xls", label tstat excel  dec(2) append
reg unique disability acc1 access i.racesex i.over40 i.super i.vet i.fedten i.agcy [aw=post], rob
outreg2 using "C:\Users\blake.emidy\OneDrive - The University of Montana\FEVS 2022\EIA_1-3-24.xls", label tstat excel  dec(2) append
reg belong disability i.racesex i.over40 i.super i.vet i.fedten i.agcy [aw=post], rob
outreg2 using "C:\Users\blake.emidy\OneDrive - The University of Montana\FEVS 2022\EIA_1-3-24.xls", label tstat excel  dec(2) append
reg belong disability acc1 access i.racesex i.over40 i.super i.vet i.fedten i.agcy [aw=post], rob
outreg2 using "C:\Users\blake.emidy\OneDrive - The University of Montana\FEVS 2022\EIA_1-3-24.xls", label tstat excel  dec(2) append

**Table 5
reg q68 disability i.racesex i.over40 i.super i.vet i.fedten i.agcy [aw=post], rob
outreg2 using "C:\Users\blake.emidy\OneDrive - The University of Montana\FEVS 2022\Levers_1-3-24.xls", label tstat excel  dec(2) append
reg q68 disability acc1 access i.racesex i.over40 i.super i.vet i.fedten i.agcy [aw=post], rob
outreg2 using "C:\Users\blake.emidy\OneDrive - The University of Montana\FEVS 2022\Levers_1-3-24.xls", label tstat excel  dec(2) append
reg q68 disability acc1 access diverse advance unique belong i.racesex i.over40 i.super i.vet i.fedten i.agcy [aw=post], rob
outreg2 using "C:\Users\blake.emidy\OneDrive - The University of Montana\FEVS 2022\Levers_1-3-24.xls", label tstat excel  dec(2) append
reg affcom disability i.racesex i.over40 i.super i.vet i.fedten i.agcy [aw=post], rob
outreg2 using "C:\Users\blake.emidy\OneDrive - The University of Montana\FEVS 2022\Levers_1-3-24.xls", label tstat excel  dec(2) append
reg affcom disability acc1 access i.racesex i.over40 i.super i.vet i.fedten i.agcy [aw=post], rob
outreg2 using "C:\Users\blake.emidy\OneDrive - The University of Montana\FEVS 2022\Levers_1-3-24.xls", label tstat excel  dec(2) append
reg affcom disability acc1 access diverse advance unique belong i.racesex i.over40 i.super i.vet i.fedten i.agcy [aw=post], rob
outreg2 using "C:\Users\blake.emidy\OneDrive - The University of Montana\FEVS 2022\Levers_1-3-24.xls", label tstat excel  dec(2) append
reg job3 disability i.racesex i.over40 i.super i.vet i.fedten i.agcy [aw=post], rob
outreg2 using "C:\Users\blake.emidy\OneDrive - The University of Montana\FEVS 2022\Levers_1-3-24.xls", label tstat excel  dec(2) append
reg job3 disability acc1 access i.racesex i.over40 i.super i.vet i.fedten i.agcy [aw=post], rob
outreg2 using "C:\Users\blake.emidy\OneDrive - The University of Montana\FEVS 2022\Levers_1-3-24.xls", label tstat excel  dec(2) append
reg job3 disability acc1 access diverse advance unique belong i.racesex i.over40 i.super i.vet i.fedten i.agcy [aw=post], rob
outreg2 using "C:\Users\blake.emidy\OneDrive - The University of Montana\FEVS 2022\Levers_1-3-24.xls", label tstat excel  dec(2) append

**Sureg analysis
sureg (advance disability acc1 i.racesex i.over40 i.super i.fedten i.agcy)(unique disability acc1 i.racesex i.over40 i.super i.fedten i.agcy)(belong disability acc1 i.racesex i.over40 i.super i.fedten i.agcy)(diverse disability acc1 i.racesex i.over40 i.super i.fedten i.agcy)(access disability acc1 i.racesex i.over40 i.super i.fedten i.agcy)(q68 advance unique belong diverse access disability acc1 i.racesex i.over40 i.super i.fedten i.agcy)(affcom advance unique belong diverse access disability acc1 i.racesex i.over40 i.super i.fedten i.agcy)(job3 advance unique belong diverse access disability acc1 i.racesex i.over40 i.super i.fedten i.agcy) [aw=post], vce(rob)

nlcom [advance]_b[disability]*[q68]_b[advance] // 
nlcom [unique]_b[disability]*[q68]_b[unique] // 
nlcom [belong]_b[disability]*[q68]_b[belong] // 
nlcom [diverse]_b[disability]*[q68]_b[diverse] 
nlcom [access]_b[disability]*[q68]_b[access]
nlcom [advance]_b[disability]*[q68]_b[advance] + [unique]_b[disability]*[q68]_b[unique] + [belong]_b[disability]*[q68]_b[belong] + [diverse]_b[disability]*[q68]_b[diverse] + [access]_b[disability]*[q68]_b[access]

nlcom [advance]_b[disability]*[affcom]_b[advance] // 
nlcom [unique]_b[disability]*[affcom]_b[unique] // 
nlcom [belong]_b[disability]*[affcom]_b[belong] // 
nlcom [diverse]_b[disability]*[affcom]_b[diverse] 
nlcom [access]_b[disability]*[affcom]_b[access]
nlcom [advance]_b[disability]*[affcom]_b[advance] + [unique]_b[disability]*[affcom]_b[unique] + [belong]_b[disability]*[affcom]_b[belong] + [diverse]_b[disability]*[affcom]_b[diverse] + [access]_b[disability]*[affcom]_b[access]

factor q45 q71-q81 [aw=post]
rotate
sortl



sureg (advance disability acc1 access i.racesex i.over40 i.super i.vet i.fedten i.agcy)(unique disability acc1 access i.racesex i.over40 i.super i.vet i.fedten i.agcy)(belong disability acc1 access i.racesex i.over40 i.super i.vet i.fedten i.agcy)(diverse disability acc1 access i.racesex i.over40 i.super i.vet i.fedten i.agcy)(q68 advance unique belong diverse access disability acc1 i.racesex i.over40 i.super i.vet i.fedten i.agcy)(affcom advance unique belong diverse disability acc1 access i.racesex i.over40 i.super i.vet i.fedten i.agcy)(job3 advance unique belong diverse access disability acc1 i.racesex i.over40 i.super i.vet i.fedten i.agcy) [aw=post], vce(rob)

nlcom [advance]_b[disability]*[q68]_b[advance] // 
nlcom [unique]_b[disability]*[q68]_b[unique] // 
nlcom [belong]_b[disability]*[q68]_b[belong] // 
nlcom [diverse]_b[disability]*[q68]_b[diverse] 
nlcom [advance]_b[disability]*[q68]_b[advance] + [unique]_b[disability]*[q68]_b[unique] + [belong]_b[disability]*[q68]_b[belong] + [diverse]_b[disability]*[q68]_b[diverse]

nlcom [advance]_b[disability]*[affcom]_b[advance] // 
nlcom [unique]_b[disability]*[affcom]_b[unique] // 
nlcom [belong]_b[disability]*[affcom]_b[belong] // 
nlcom [diverse]_b[disability]*[affcom]_b[diverse] 
nlcom [advance]_b[disability]*[affcom]_b[advance] + [unique]_b[disability]*[affcom]_b[unique] + [belong]_b[disability]*[affcom]_b[belong] + [diverse]_b[disability]*[affcom]_b[diverse]

nlcom [advance]_b[disability]*[job3]_b[advance] // 
nlcom [unique]_b[disability]*[job3]_b[unique] // 
nlcom [belong]_b[disability]*[job3]_b[belong] // 
nlcom [diverse]_b[disability]*[job3]_b[diverse] 
nlcom [advance]_b[disability]*[job3]_b[advance] + [unique]_b[disability]*[job3]_b[unique] + [belong]_b[disability]*[job3]_b[belong] + [diverse]_b[disability]*[job3]_b[diverse]













